﻿@using Model.WXshopBuiness;
@using Model.Util.DTO;
@using Model.Util;
@using Xproject.Util;
@{
    Layout = "~/Views/Shared/_JSlayout.cshtml";
    string Domain = CommonHelper.GetAppSettings("Domin");
   
    List<Promotions> promotions = (List<Promotions>)ViewData["Promotions"];     
}
@model WXProduct

<div class="gray-bg">
    <div class="  animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">

                    <div class="ibox-content">
                        <form class="form-horizontal m-t" id="formProductpromotion" action="~/Promotions/EditProductPromotions" method="post">
                            <div class="form-group">
                                <label class="col-sm-3 control-label">产品名：</label>
                                <div class="col-sm-8">
                                    <input id="ProductName" name="ProductName" class="form-control" type="text" disabled="disabled" required maxlength="20" value="@(Model!=null?Model.ProductName:"")">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">产品描述：</label>
                                <div class="col-sm-8">
                                    <input id="ShortDesc" name="ShortDesc" class="form-control" type="text" disabled="disabled" aria-required="true" aria-invalid="false" value="@(Model!=null?Model.ShortDesc:"")" required>
                                </div>
                            </div>
                            <div class="form-group">
                                @if (Model != null)
        {
                        <label class="col-sm-3 control-label">产品编码：</label>
                        <div class="col-sm-8">
                            <input id="ProductCode" readonly disabled="disabled" name="ProductCode" class="form-control" type="text" aria-required="true" aria-invalid="true" value="@(Model != null ? Model.ProductCode : "")" required>
                        </div>
}
                            </div>




                            <div class="form-group">
                                <label class="col-sm-2 control-label">活动配置：</label>
                                <div class="col-sm-12 ">


                                    <select class="form-control" id="promotionId" name="promotionId">
                                        <option>请选择</option>
                                        @foreach (Promotions info in promotions)
                {
                        <option @if (info.PromotionID == Model.PromotionId) { <text> selected="selected" </text> }
                                value="@info.PromotionID">
                            @(info.PromotionName +   info.Remarks)
                        </option>
}
                                    </select>

                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-sm-8 col-sm-offset-3">
                                    <input  name="ProductID" value="@Model.ProductID" type="hidden"/>
                                    <button class="btn btn-primary" type="submit">提交</button>
                                </div>
                            </div>



                        </form>
                    </div>
                </div>
            </div>
        </div>

    </div>
</div>
<script type="text/javascript">
    $(document).ready(function () {
        var optionsNew = {
            beforeSubmit: function () {
                //layer.open({ type: 2, time: 2 });
                layer.load(1, { shade: [0.1, '#000'], time: 2000 });
            },
            success: function (data) {
                if (data.Success == true) {
                    layer.alert('编辑成功', { icon: 1, skin: 'layer-ext-moon', time: 2000 });
                } else {
                    layer.alert(data.Data, { icon: 1, skin: 'layer-ext-moon', time: 2000 });
                }
            },
            error: function () {
                alert(JSON.stringify(data));
            },
            type: "post",
            clearForm: false,
            timeout: 100000
        };

        $("#formProductpromotion").submit(function () {
            $("#formProductpromotion").ajaxSubmit(optionsNew);// type="button"
            return false;
        });
    });


</script>